<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */

class Default_Form_ValidateActiveAccount{
	
    protected $_isError = false;
	protected $_messageError = null;
    protected $_arrData = null;
    protected $_classError = null;
    
    public function __construct($params = array(), $register = false){
        
        $translate = Zend_Registry::get('Zend_Translate');
        
        $validateEmail = new Zend_Validate();
        $validateCode = new Zend_Validate();
        
        $optionEmail = array('table' => 'accounts', 'field' => 'email');
        
        $validateEmail->addValidator(new Zend_Validate_NotEmpty, true)
                        ->addValidator(new Zend_Validate_StringLength(array('max' => 255)), true)
                        ->addValidator(new Zend_Validate_EmailAddress(), true)
                        ->addValidator(new Zend_Validate_Db_RecordExists($optionEmail), true);
        
        /*  
        * Check Email
        */
        
        if(!$validateEmail->isValid($params['email'])){
            $this->_messageError['email'] = '<label id="email" class="required"><em>' . $translate->_('email error') . '</em></label>';
            $this->_isError = true;
            $this->_arrData['email'] = '';
        }else{
            $this->_messageError['email'] = '';
            $this->_arrData['email'] = $params['email'];
        }
    }
    
    public function isError(){
    	return $this->_isError;
    }
    
    public function getMessageError(){
        return $this->_messageError;
    }
    
    public function getClassError(){
    	return $this->_classError;
    }
    
    public function getData(){
        return $this->_arrData;
    }
}